package de.tum.in.eist.poll.shared;

import java.io.Serializable;

/**
 * Representation of a user.
 */
@SuppressWarnings("serial")
public class User implements Serializable {

	/**
	 * The user's unique name.
	 */
	private String name;

	/**
	 * The user's unique password.
	 */
	private String password;

	/**
	 * The user's login status.
	 */
	private boolean loggedIn;

	/**
	 * The number identifying the user's row in the database.
	 */
	private int userID = -1;
	
	/**
	 * The user's type/privilege level, with 0 = student, 1 = lecturer, 2 = admin
	 */
	private int userType = 0;

	/**
	 * Default zero-argument constructor.
	 * 
	 * @deprecated
	 */
	public User() {

	}
	
	/**
	 * Limited constructor for use during login.
	 */
	public User(String name, String password) {
		this.name = name;
		this.password = password;
	}

	/**
	 * @param name
	 *            {@link #name}
	 * @param password
	 *            {@link #password}
	 */
	public User(String name, String password, int uid) {
		this.name = name;
		this.password = password;
		this.userID = uid;
	}
	
	/**
	 * Full constructor for use during login.
	 */
	public User(String name, String password, int uid, int userType) {
		this.name = name;
		this.password = password;
		this.userID = uid;
		this.userType = userType;
	}

	/**
	 * @return the {@link #name}.
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return the {@link #password}.
	 */
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the {@link #loggedIn}.
	 */
	public boolean isLoggedIn() {
		return loggedIn;
	}

	/**
	 * Set login status to true
	 */
	public void login() {
		this.loggedIn = true;
	}

	/**
	 * Set login status to false
	 */
	public void logout() {
		this.loggedIn = false;
	}

	/**
	 *@return The user identification number as stored in the database.
	 */
	public int getID() {
		return userID;
	}
	
	/**
	 * @return The user's type, representing the the privilege level.
	 */
	public int getUserType() {
		return userType;
	}

}

